package com.baidu.service.impl;

import com.baidu.entity.ShoppingCart;
import com.baidu.mapper.ShoppingCartMapper;
import com.baidu.service.ShoppingCartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @描述
 * @Author ShoppingCartServiceImpl
 * @Date 2019/4/24 18:18
 **/
@Service("shoppingCartService")
public class ShoppingCartServiceImpl implements ShoppingCartService {
    @Resource
    private ShoppingCartMapper shoppingCartMapper;


    /**
     * 添加购物车信息
     * @param sname
     * @param quantity
     * @param stotalprice
     * @param sprice
     * @return
     */
    @Override
    public Integer insertShopping(String sname, String quantity, BigDecimal stotalprice, BigDecimal sprice) {
        ShoppingCart shoppingCart=new ShoppingCart();
        shoppingCart.setSprice(sprice);
        shoppingCart.setStotalprice(stotalprice);
        shoppingCart.setSname(sname);
        shoppingCart.setQuantity(quantity);
        Integer i = shoppingCartMapper.insertShopping(shoppingCart);
        return i;
    }

    /**
     * 查询
     * @return
     */
    @Override
    public List<ShoppingCart> selectShopping() {
        return shoppingCartMapper.selectShopping();
    }
}
